package components.views.filters
{
	import controls.interaction.InteractionCenter;
	import data.FilterRange;
	import flexlib.controls.HSlider;
	
	import mx.containers.Canvas;
	import mx.events.SliderEvent;

	public class GpaFilter extends Canvas
	{
		private var slider:HSlider;
		private var iCenter:InteractionCenter;
		
		public function GpaFilter()
		{
			super();
			
			iCenter = InteractionCenter.instance;
			setComponents();
		}
		
		private function setComponents():void
		{
			slider = new HSlider();
			slider.minimum = 0;
			slider.maximum = 4.0;
			slider.lockRegionsWhileDragging = true;
			slider.showDataTip = true;
			slider.allowThumbOverlap = false;
			slider.tickValues = [0, 1.0, 2.0, 3.0, 4.0];
			slider.thumbCount = 2;
			slider.percentWidth = 100;
			slider.percentHeight = 100;
			slider.values = [0, 4.0];
			this.addChild(slider);
			slider.addEventListener(SliderEvent.CHANGE, onSlide);
			slider.addEventListener(SliderEvent.THUMB_RELEASE, onSlide);
		}
		
		private function onSlide(evt:SliderEvent):void
		{
			iCenter.applyFilter(new FilterRange(Filters.GPA_FILTER, slider.values[0], slider.values[1]));
		}
	}
}